﻿using System;
using System.Numerics;

class CardWars
{
    static void Main()
    {
        int numberOfAllGames = int.Parse(Console.ReadLine());
        const int cardsToPlayer = 3;
        BigInteger playerOneGlobalScore = 0;
        BigInteger playerTwoGlobalScore = 0;
        bool xCardDrawnByPlayerOne = false;
        bool xCardDrawnByPlayerTwo = false;
        int gamesWonByPlayerOne = 0;
        int gamesWonByPlayerTwo = 0;

        for (int i = 0; i < numberOfAllGames; i++)
        {
            int currentPlayerOneGameScore = 0;
            int currentPlayerTwoGameScore = 0;

            for (int j = 0; j < cardsToPlayer; j++)
            {
                string currentCard = Console.ReadLine();

                switch (currentCard)
                {
                    case "J": currentPlayerOneGameScore += 11;
                        break;
                    case "Q": currentPlayerOneGameScore += 12;
                        break;
                    case "K": currentPlayerOneGameScore += 13;
                        break;
                    case "A": currentPlayerOneGameScore += 1;
                        break;
                    case "Z": playerOneGlobalScore *= 2;
                        break;
                    case "Y": playerOneGlobalScore -= 200;
                        break;
                    case "X": xCardDrawnByPlayerOne = true;
                        break;
                    default: currentPlayerOneGameScore += 12 - int.Parse(currentCard);
                        break;
                }
            }
            for (int j = 0; j < cardsToPlayer; j++)
            {
                string currentCard = Console.ReadLine();

                switch (currentCard)
                {
                    case "J": currentPlayerTwoGameScore += 11;
                        break;
                    case "Q": currentPlayerTwoGameScore += 12;
                        break;
                    case "K": currentPlayerTwoGameScore += 13;
                        break;
                    case "A": currentPlayerTwoGameScore += 1;
                        break;
                    case "Z": playerTwoGlobalScore *= 2;
                        break;
                    case "Y": playerTwoGlobalScore -= 200;
                        break;
                    case "X": xCardDrawnByPlayerTwo = true;
                        break;
                    default: currentPlayerTwoGameScore += 12 - int.Parse(currentCard);
                        break;
                }
            }

            if (xCardDrawnByPlayerOne && xCardDrawnByPlayerTwo)
            {
                playerOneGlobalScore += 50;
                playerTwoGlobalScore += 50;

                xCardDrawnByPlayerOne = false;
                xCardDrawnByPlayerTwo = false;
            }
            else if (xCardDrawnByPlayerOne)
            {
                break;
            }
            else if (xCardDrawnByPlayerTwo)
            {
                break;
            }

            if (currentPlayerOneGameScore > currentPlayerTwoGameScore)
            {
                playerOneGlobalScore += currentPlayerOneGameScore;
                gamesWonByPlayerOne++;
            }
            else if (currentPlayerOneGameScore < currentPlayerTwoGameScore)
            {
                playerTwoGlobalScore += currentPlayerTwoGameScore;
                gamesWonByPlayerTwo++;
            }
        }

        if (xCardDrawnByPlayerOne)
        {
            Console.WriteLine("X card drawn! Player one wins the match!");
        }
        else if (xCardDrawnByPlayerTwo)
        {
            Console.WriteLine("X card drawn! Player two wins the match!");
        }
        else if (playerOneGlobalScore > playerTwoGlobalScore)
        {
            Console.WriteLine("First player wins!");
            Console.WriteLine("Score: {0}", playerOneGlobalScore);
            Console.WriteLine("Games won: {0}", gamesWonByPlayerOne);
        }
        else if (playerOneGlobalScore < playerTwoGlobalScore)
        {
            Console.WriteLine("Second player wins!");
            Console.WriteLine("Score: {0}", playerTwoGlobalScore);
            Console.WriteLine("Games won: {0}", gamesWonByPlayerTwo);
        }
        else
        {
            Console.WriteLine("It's a tie!");
            Console.WriteLine("Score: {0}", playerOneGlobalScore);
        }
    }
}

